Skip to content

feat: add validators for tasks_max, unit_slice, tbf_size, nsec, permille#443

Merged
SJrX merged 1 commit into
242.xfrom
issue-442
May 23, 2026
Merged

feat: add validators for tasks_max, unit_slice, tbf_size, nsec, permille#443
SJrX merged 1 commit into
242.xfrom
issue-442

Conversation

@SJrX
Copy link
Copy Markdown
Owner

@SJrX SJrX commented May 23, 2026

Summary

Implements 5 new validators selected for high usage count + simple, verifiable C parser semantics. Each grammar matches the actual systemd C parser, not man-page prose — addressing the prior-cycle finding that AI-generated validators tend to look right but mismatch real semantics.

Validator C source Usages
config_parse_tasks_max(0) src/core/load-fragment.c:3821 6
config_parse_unit_slice(0) src/core/load-fragment.c:3635 6
config_parse_tbf_size(QDISC_KIND_TBF) src/network/tc/tbf.c:111 6
config_parse_nsec(0) src/basic/time-util.c:1358 (parse_nsec) 5
config_parse_permille(0) src/shared/conf-parser.c:1775src/basic/percent-util.c:125 2

OptionValueTest missing-function count drops 405 → 400; found-key count rises 1719 → 1744 (25 newly-validated key occurrences across [Service], [Mount], [Socket], [Swap], [TokenBucketFilter], [CAN]).

Resolves #442.

Stacking

Branches off issue-440 (the DHCP relay deprecation fix) — merge that one first or rebase onto 242.x after #441 lands.

Test plan

  • All 5 new test classes pass (valid + invalid cases per validator)
  • OptionValueTest passes (400 < 411 allowed today)
  • SemanticDataRepositoryTest passes (all new validators backed by gperf entries)
  • Full suite passes (./gradlew test -x generateDataFromManPages, 1021 tests)
  • CI green on the PR

Notes

  • ASCII percent form only for tasks_max and permille; the Unicode / suffixes accepted by the C parser are vanishingly rare in real unit files. If users hit a false positive, easy follow-up.
  • unit_slice accepts .slice-terminated names or anything with a % specifier (which expands at runtime to potentially anything). Whitespace-separated lists are not accepted, matching the C parser.

🤖 Generated with Claude Code

…lle (Resolves #442)

Each grammar mirrors the systemd C parser semantics rather than guessing
from man-page prose:

- config_parse_tasks_max: "infinity" | positive uint64 | 0..100(.NN)?% (parse_permyriad)
- config_parse_unit_slice: single token, ".slice" suffix unless containing a specifier
- config_parse_tbf_size (QDISC_KIND_TBF): IEC byte-size grammar, same shape as config_parse_fq_size
- config_parse_nsec: existing TIME_VALUE grammar (parse_nsec accepts the same syntax as parse_sec)
- config_parse_permille: 0..100(.x)?% (ASCII percent form of parse_permille)

Reduces OptionValueTest missing-function count from 405 to 400 and adds
25 newly-validated key occurrences across [Service], [Mount], [Socket],
[Swap], [TokenBucketFilter], and [CAN] sections.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@SJrX SJrX changed the base branch from issue-440 to 242.x May 23, 2026 16:10
@github-actions
Copy link
Copy Markdown

Test Results

1 024 tests  +10   1 024 ✅ +10   46s ⏱️ +3s
  251 suites + 5       0 💤 ± 0 
  251 files   + 5       0 ❌ ± 0 

Results for commit b93d5ea. ± Comparison against base commit 28ecc65.

@SJrX SJrX merged commit 5065f32 into 242.x May 23, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement 5 high-ROI validators (tasks_max, unit_slice, tbf_size, nsec, permille)

1 participant